<?php

/**
 * 测试api接口
 * @author yuxun
 *
 */
class TextApiController extends Controller {

	public function __construct($id,$module=null){
		parent::__construct();
	}
	
	
	
	public function text_kick_out(){
		$api_key = 'P2JZFD9VK5VOJL7S';
		$url = 'http://120.78.80.94:8090/api/?r=tutelage/kick_out';
		//$url = 'http://www.tm.com/api/?r=tutelage/kick_out';
		$post_arr = array('uid'=>'test0001','ditch_id'=>'0','time'=>time()+60);
		ksort($post_arr);
		$post_arr['sign'] = md5(http_build_query($post_arr).$api_key);
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);exit;
		
	}
	
	public function text_forbid(){
		$api_key = 'IFHCBDKCM963G1VD';
		//$url = 'http://www.tm.com/api/?r=chat/forbid';
		//$url = 'http://120.78.80.94:8090/api/?r=chat/forbid';
		$url = 'http://admin.s10.q-dazzle.com:8090/api/?r=chat/forbid';
		//$post_arr = array('game_name'=>'S10','plat_cname'=>'cszf','server_id'=>'2','plat_user_name'=>'test0','role_id'=>'20010628','forbid_time'=>60,'type'=>'forbid'); //封号
		//$post_arr = array('game_name'=>'S10','plat_cname'=>'cszf','server_id'=>'2','plat_user_name'=>'test0','role_id'=>'20010628','forbid_time'=>60,'type'=>'mute'); //禁言
		//$post_arr = array('game_name'=>'S10','plat_cname'=>'cszf','server_id'=>'2','plat_user_name'=>'test0','role_id'=>'20010628','forbid_time'=>60,'army_id'=>1,'type'=>'army_kickout'); //踢出帮派
		
		$post_arr = array('game_name'=>'S10','plat_cname'=>'90389','server_id'=>'1','plat_user_name'=>'11876hd1134247','role_id'=>'10010095','forbid_time'=>0,'type'=>'forbid'); //封号
		//$post_arr = array('game_name'=>'S10','plat_cname'=>'90001','server_id'=>'1','plat_user_name'=>'test0001','role_id'=>'10010095','forbid_time'=>0,'type'=>'mute'); //禁言
		//$post_arr = array('game_name'=>'S10','plat_cname'=>'90001','server_id'=>'1','plat_user_name'=>'test0001','role_id'=>'10010095','forbid_time'=>60,'army_id'=>1,'type'=>'army_kickout'); //踢出帮派
		
		ksort($post_arr);
		$post_arr['sign'] = md5($api_key.http_build_query($post_arr));
		//$url = $url."&sign=".$post_arr['sign'];
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);exit;
	
	}
	
	public function text_game_all(){
		$api_key = 'P2JZFD9VK5VOJL7S';
		$url = 'http://192.168.1.10:30011/v1/game/all';
		$post_arr = array();
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);exit;
	
	}
	
	public function text_channel(){
		$api = new ApiSynchro();
		
		$channelConfig['channel_id'] = "0";
		$channelConfig['game_list'][] = 'game_yace1';
		$channelConfig['game_list'][] = 'game_yace2';

		$result = $api->channelEdit($channelConfig);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_check(){
		$key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		$params = array();
		$params['channel_id'] = 199;
		$params['account'] = 'xujiawen';
		$params['role_id'] = '11111';
		$params['grade'] = '70';
		$params['code'] = 'jiaNltWJhka';
		//$params['code'] = 'xuQpaYKhr7';

		 
		ksort($params);
		foreach($params as $k=>$v){
			$str .= '&'.$k.'='.$v;
		}
		$str = substr($str,1);
		//$sign = $key.$str;
		$sign = md5($key.$str);
		 
		$data = array();
		$data = $params;
		$data['sign'] = $sign;
		 
		$url = 'http://www.tm.com/api/?r=code/check';
		$result = PubFunc::request($url, $data, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_url(){
		$key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		$params = array();
		$params['packet'] = '0';
		$params['version'] = '2.0.1.4';
		
		ksort($params);
		foreach($params as $k=>$v){
			$str .= '&'.$k.'='.$v;
		}
		$str = substr($str,1);
		$sign = md5($key.$str);
			
		$data = array();
		$data = $params;
		$data['sign'] = $sign;
			
		$url = 'http://192.168.1.10:8090/api/?r=ios/getUrl';
		$url = 'http://www.tm.com/api/?r=ios/getUrl';
		$result = PubFunc::request($url, $data, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	
	public function text_monitor(){
		$api_key = 'XZLr3583Vj3Yth8t';
		//$url = 'http://www.tm.com/api/?r=serverState/monitor';
		$url = 'http://admin.s10.q-dazzle.com:8090/api/?r=serverState/monitor';
		$game_id = 30;
		$time = time();
		$post_arr = array('game_id'=>$game_id,'time'=>$time);
		//$sign = $game_id.'&'.$time.'&'.$api_key;
		$sign = md5($game_id.'&'.$time.'&'.$api_key);
		$post_arr['sign'] = $sign;
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);
		$a = json_decode($result['result'],true);
		//var_dump($a);
		exit;
	
	}
	
	public function text_add_server(){
		$json_array = array();
			
		$key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		$json_array['id'] = 8;
		$json_array['server_name'] = 'yuxun';
		$json_array['develop_id'] = 'xxxxx24911111';
		$json_array['server_num'] = '11';
		$json_array['oss_api'] = 'http://192.168.1.10:11111/gm/';
		$json_array['log_server'] = '192.168.1.10';
		$json_array['ip'] = '192.168.1.10';
		$json_array['port'] = '3306';
		$json_array['open_time'] = '1536132303';
		//$json_array['union_time'] = '1536132303';
		//$json_array['union_to'] = '';
		$json_array['status'] = '1';
		$json_array['channel_list'] = 'IOS审核';
		$json_array['special_id'] = 'IOS审核服';
		$json_array['name'] = '哈哈哈';
		$json_array['sort_num'] = 1;
		$json = json_encode($json_array);
		$params = array();
		$params['json_data'] = $json;
		$time = time();
		 
		ksort($params);
		foreach($params as $k=>$v){
			$str .= $k.$v;
		}
			
		$str = $str.$time.$key;
		$sign = strtoupper(md5($str));
			
		$data = array();
		$data = $params;
		$data['time'] = $time;
		$data['sign'] = $sign;
	
		$url = 'http://www.tm.com/api/?r=server/addServer';
		$result = PubFunc::request($url, $data, 10);
		echo '<pre>';
		var_dump($result);exit;
			
	}
	
	public function text_get_plat(){
		$api_key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';		
		//$url = 'http://www.tm.com/api/?r=dataCenter/getPlatList';
		$url = 'http://admin.s10.q-dazzle.com:8090/api/?r=dataCenter/getPlatList';
		$post_arr = array();
		ksort($post_arr);
		$post_arr['sign'] = md5($api_key.http_build_query($post_arr));
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_get_server(){
		$api_key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		//$url = 'http://www.tm.com/api/?r=dataCenter/getServerList';
		$url = 'http://admin.s10.q-dazzle.com:8090/api/?r=dataCenter/getServerList';
		$post_arr = array();
		ksort($post_arr);
		$post_arr['sign'] = md5($api_key.http_build_query($post_arr));
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_get_inside(){
		$api_key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		//$url = 'http://www.tm.com/api/?r=dataCenter/getInsideList';
		$url = 'http://admin.s10.q-dazzle.com:8090/api/?r=dataCenter/getInsideList';
		$post_arr = array();
		ksort($post_arr);
		$post_arr['sign'] = md5($api_key.http_build_query($post_arr));
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_get_login_num(){
		$api_key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		//$url = 'http://www.tm.com/api/?r=dataCenter/getLoginNum';
		$url = 'http://admin.s10.q-dazzle.com:8090/api/?r=dataCenter/getLoginNum';
		$post_arr = array();
		$post_arr['plat_id'] = '90389';
		$post_arr['server_id'] = '10002';
		//$post_arr['server_id'] = '1';
		$post_arr['date'] = '2018-11-11';
		$post_arr['time'] = time();
		
		ksort($post_arr);
		$post_arr['sign'] = md5($api_key.http_build_query($post_arr));
		$result = PubFunc::request($url, $post_arr, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_add_message(){
		$key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		$params = array();
// 		$params['channel'] = '0';
// 		$params['server'] = 'game2';
// 		$params['role_id'] = 10000010613;
// 		$params['role_name'] = '叶迪喻';
// 		$params['role_level'] = 100;
// 		$params['desc'] = '意见反馈';

		$params['channel'] = '0';
		$params['server'] = 'game1';
		$params['role_id'] = 10000010746;
		$params['role_name'] = '乐弘非';
		$params['role_level'] = 201;
		$params['desc'] = 'dsajidhjksa';
	
		ksort($params);
		foreach($params as $k=>$v){
			$str .= '&'.$k.'='.$v;   
		}
		$str = substr($str,1);
// 		echo $str;echo'<br/>';
// 		echo $key.$str;echo'<br/>';
		$sign = md5($key.$str);
// 		echo $sign;echo'<br/>';
			
		$data = array();
		$data = $params;
		$data['sign'] = $sign;
			
		//$url = 'http://192.168.1.10:8090/api/?r=message/addMessage';
		$url = 'http://www.tm.com/api/?r=message/addMessage';
		$result = PubFunc::request($url, $data, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_rechargeUrl(){
		$key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		$params = array();
		$params['channel'] = '0';
		$params['packet'] = '13';
	
		ksort($params);
		foreach($params as $k=>$v){
			$str .= '&'.$k.'='.$v;
		}
		$str = substr($str,1);
		$sign = md5($key.$str);
			
		$data = array();
		$data = $params;
		$data['sign'] = $sign;
			
		$url = 'http://192.168.1.10:8090/api/?r=ios/getRechargeUrl';
		//$url = 'http://www.tm.com/api/?r=ios/getRechargeUrl';
		$result = PubFunc::request($url, $data, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
	public function text_verInfo(){
		$key = 'BF1A9DAFF92587A7FC93A6BB59230DA8';
		$params = array();
		$params['channel'] = '11876';
	
		ksort($params);
		foreach($params as $k=>$v){
			$str .= '&'.$k.'='.$v;
		}
		$str = substr($str,1);
		$sign = md5($key.$str);
			
		$data = array();
		$data = $params;
		$data['sign'] = $sign;
			
		$url = 'http://192.168.1.10:8090/api/?r=record/getVerInfo';
		//$url = 'http://www.tm.com/api/?r=record/getVerInfo';
		$result = PubFunc::request($url, $data, 10);
		echo '<pre>';
		var_dump($result);exit;
	}
	
   

}